<?php


namespace app\api\model;


use app\common\lib\RespCode;
use think\Db;
use think\Exception;
use think\Model;

class UserProblem extends Model {

    /**
     * 添加反馈
     * @param $params
     * @return int|string
     */
    public static function add($params) {
        if (mb_strlen($params['content'], "utf-8") > 100) {
            throw new Exception('内容不能超过100个字符', RespCode::QUERY_ERR);
        }
        $data = [
            'user_id' => $params['user_id'],
            'content' => $params['content'],
            'pic' => empty($params['pic']) ? '' : $params['pic'],
            'itime' => time()
        ];
        return Db::name("user_problem")->insert($data);
    }


}
